package com.echat.companydata.tool;


/**
 * Created by xiaoyu on 2015/7/23.
 */
public class ChatRedisKeys {
    public static final String RedisName_Chat = "chat";//定义redis链接的名字，可以链接多个redis
    public static final String RedisName_HealthCheck = "healthcheck";//健康检查redis
    public static final String RedisName_ChatSupport = "chatSupport";//对话帮助redis

    public static final String chatKeysPrefix = "chat_";//未避免出现重复的key每个应用在使用key的时候将其应用名作为前缀使用
    public static final String keySplit = "_";//分隔符
    public static final String chatProfileKeysPrefix = "chatprofile_";//未避免出现重复的key每个应用在使用key的时候将其应用名作为前缀使用
    public static final String chatApiKeysPrefix = "chatapi_";//chatapi项目前缀
    public static final String wechatKeysPrefix = "wechat_";//此模块所有key的前缀 避免重复
    public static final String reportKeysPrefix = "report_";
    public static final String robotKeysPrefix = "robot_";//机器人项目前缀
    public static final String commonKeysPrefix = "common_";//模块可共用的
    public static final String eventLimitKeysPrefix = "eventlimit_";//事件限制前缀
    /*
    公司客服列表缓存，在客服登陆后需要读取本公司的客服列表，次列表缓存在redis中,(所有客服信息，已登录的客服信息也在这里体现)
     hash
     */
    public static final String staffInfo = "staffInfo_";

    public static final String i18nStaffInfo = "i18nStaffInfo_";

    /**
     * 客服对外信息 hash结构存储，用于缓存客服
     */
    public static final String staffExtInfo = "staffExtInfo_";
    /*
    客服在线状态维护，用来判断当前公司是否有客服在线，同时修改公司的在线状态
     hash
     */
    public static final String staffStatus = "staffStatus_";
    public static final String companyStatus = "companyStatus";//在此hash下保存公司状态的键值
    public static final String departmentStatus = "departmentStatus_";//某公司的部门状态缓存,hash存储 key为部门ID value为部门状态
    public static final String routeStatus = "routeStatus_";//公司的路由状态 hash存储key为路由ID value为路由状态
    public static final String staffLoginMedia = "staffLoginMedia_";//客服登陆媒介
    /*
     hash存储公司的角色列表对应的权限码，在某个角色有更新后刷新此redis通知相关应用
     key:roleId value:privilegecode
     */
    public static final String rolePrivilege = "rolePrivilege_";
    /*
     客服对应的角色关系，在客服角色重新分配后更新redis通知其他应用
     hash存储
     key：staffid value：roleid
     */
    public static final String staffRole = "staffRole_";
    /*
     客服所属部门的列表，所有客服，在客服状态变更或者客服部门变更的时候同步此redis
     hash结构  key:staffId value:所属部门ID值，逗号分隔
     */
    public static final String staffDepartment = "staffDepartment_";

    /*
       公司对应的版本信息
     */
    public static final String companyVersionRef = "companyVersionRef";

    /**
     * 公司版本扩展信息
     */
    public static final String companyVersionExtRef = "companyVersionExtRef";
    /*
       公司对应的机器人版本
     */
    public static final String robotVersionRef = "robotVersionRef";

    /*
       版本配置缓存
     */
    public static final String version = "version";
    /**
     * 客服所属样式的关系缓存
     * hash结构
     * key：staffId value：所可以见的路由列表，逗号分割
     */
    public static final String staffRoute = "staffRoute_";
    /*
    客服状态时间详情，用于记录客服在各个时间段内的时长，在线时长
     */
    public static final String staffStatusTime = "staffStatusTime_";
    /**
     * 如果客服正在登陆那么在处理退出的时候就等待登陆成功后退出避免闪退造成的脏数据驻留redis
     */
    public static final String staffLoginingStatus = "staffLoginingStatus";
    /**
     * 同时维护httpsession的创建和销毁，在httpsession销毁的时候检测是否有指定客服的httpsession存在，在没有httpsession的时候确定cometd的session维护
     * 已销毁
     * hash存储
     * key:httpSessionStaffInfo_${companyId}
     */
    public static final String httpSessionStaffInfo = "httpSessionStaffInfo_";
    /**
     * 公司对话列表（已开始和未开始的对话） hash存储 key:visitorId:value: ChatInfoMsg
     */
    public static final String companyChatMap = "companyChatMap_";

    /**
     * 公司离线消息列表 hash存储 key：visitorId，value：OfflineMsg
     */
    @Deprecated
    public static final String companyOfflineMap = "companyOfflineMap_";

    /**
     * 新版公司离线列表 hash存储 key：visitorId_routeId，value：OfflineMsg
     */
    public static final String companyOfflineV2Map = "companyOfflineV2Map_";

    /**
     * 当前公司访客未回复计时监控
     * hash  存储
     * key:comChatVUnSendMap_${companyId}
     * key:visitorId
     * value:ChatUnSendMonitorInfo
     */
    public static final String companyChatVisitorUnSendMap = "comChatVUnSendMap";

    /**
     * 当前公司客服未回复访客监控
     * hash存储
     * key:comChatSUnSendMap_${companyId}
     * * key:visitorId
     * value:ChatUnSendMonitorInfo
     */
    public static final String companyChatStaffUnSendMap = "comChatSUnSendMap";

    /**
     * 当前公司忙碌自动应答监控
     * hash存储
     * key:comChatBusyAPMap_${companyId}
     * * key:visitorId
     * value:ChatBusyAutoReplyMonitorInfo
     */
    public static final String companyChatBusyAutoReplyMap = "comChatBusyAPMap";

    /**
     * 记录当前公司的访客列表消息  key:visitorId:value:VisitorInfoMsg
     */
    public static final String companyVisitorMap = "companyVisitorMap_";
    /**
     * 邀请访客列表 保存本公司被邀请的访客的列表,在访客发起对话的时候优先分配给邀请的客服
     * hash存储key:visitorId:value:当前访客被邀请消息 VisitorBeInvitedMsg
     */
    public static final String companyBeInvitedMap = "companyBeInvitedMap_";
    /**
     * 邀请主动对话访客列表 保存   long chatCount = ChatDataStatusUtil.getCompanyTotalChatNumber(companyId);本公司主动对话的访客的列表,在访客发起对话的时候如果主动对话的客服在线分配给发起主动对话的客服
     * hash存储key:visitorId:value:当前访客被邀请消息 VisitorBeInitiativeChatMsg
     */
    public static final String companyBeInitiativeChatMap = "companyBeInitiativeMap_";
    /**
     * 客服被监控列表 保存某个客服被哪些客服监控
     * set类型
     * key：beMonitored_${companyId}_${staffId}
     */
    public static final String staffBeMonitoredSet = "staffBeMonitored_";
    /**
     * 客服监控列表 保存都监控了哪些客服
     * set类型
     * key:staffMonitor_${companyId}_${staffId}
     */
    public static final String staffMonitorSet = "staffMonitor_";
    /**
     * 访客浏览轨迹列表 保存某个访客的浏览轨迹
     * list类型 保证顺序
     * key:visitorTrackSet_${companyId}_${visitorId}
     */
    public static final String visitorTrackList = "visitorTrackList_";
    /**
     * 对话访客的对话记录列表 保存某个对话的对话消息
     * list类型保持顺序
     * key:chatDetailSet_${companyId}_${visitorId}
     */
    public static final String chatDetailList = "chatDetailSet_";
    /*
       将未读的对话消息临时保存在另一个队列，在对话结束时进行处理移除，避免存在获取未读消息时不必要的过滤以及复杂的未读消息列表的增删操作
       在手机对话中有可能将原本服务器认为已读的消息设置为未读消息
     */
    public static final String unreadChatDetailList = "unreadChatDetailSet_";
    public static final String chatDetailTranslationList = "chatDetailTranslationList_";
    public static final String offlineDetailList = "offlineDetailSet_";
    public static final String offlineDetailTranslationList = "offlineDetailTranslationList_";

    public static final String pushInfoSet = "pushInfoSet_";

    public static final String robotDetailList = "robotDetailSet_";

    public static final String chatInfoArchive = "chatInfoArchive_";

    public static final String routeHotTopics = "routeHotTopics_";

    public static final String synchronizedFlag = "synchronizedFlag_";
//    /**
//     * 记录当前客服的对话列表消息companyId-staffId   key:visitorId:value:当前访客的类型，因为hash允许删除指定的值且可去重，所以选用hash而非list
//     */
//    public static final String staffChatMap = "staffChatMap";
//
//    public static String getStaffChatListKey(long companyId,long staffId) {
//        return new StringBuffer().append(chatKeysPrefix).append(staffChatMap).append(companyId).append("_").append(staffId).toString();
//
//    }
    /**
     * 访客端serversession列表，因为访客端可以打开多个页面，所以会有多个serversession。
     * hash结构：key：serversessionid value：trackinfo
     * key:visitorSessions_${companyId}_${visitorId}
     */
    public static final String visitorSessionMap = "visitorSessions_";
    /**
     * 访客来访次数以及详细信息缓存，在访客回访的时候先从缓存取如果没有则从数据库取
     * string类型 保存需要用到的信息VisitorDetailCache：
     * key:visitorDetail_${companyId}_${visitorId
     */
    public static final String visitorDetailCache = "visitorDetailCache_";
    /**
     * 访客ip黑名单缓存
     * string类型 保存需要用到的信息visitorBlackListIpCache：
     * key:visitorBlackListIpCache_${companyId}_${ip}
     */
    public static final String visitorBlackListIpCache = "visitorBlackListIpCache_";
    /**
     * 访客is黑名单缓存
     * string类型 保存需要用到的信息visitorBlackListIpCache：
     * key:visitorBlackListIpCache_${companyId}_${visitorId}
     */
    public static final String visitorBlackListIdCache = "visitorBlackListIdCache_";
    /**
     * 对话访客端serversession列表，因为访客端可以打开多个页面，所以会有多个serversession。
     * hash结构：key：serversessionid value：${time}
     * key:chaterSessions_${companyId}_${visitorId}
     */
    public static final String chaterSessionMap = "chaterSessions_";

    /**
     * 留言访客端serversession列表，因为访客端可以打开多个页面，所以会有多个serversession。
     */
    public static final String offlineSessionMap = "offlineSessions_";

    /**
     * 对话关闭原因缓存 因为由于网络或者其他原因，可能导致已经结束的对话访客或者客服还在请求，此时我们将对话结束的原因缓存30秒供后期的调用使用
     * string类型
     * key：chatCloseReasonCache_${companyId}_${visitorId}
     */
    public static final String chatCloseReasonCache = "chatCloseReasonCache_";
    /**
     * 数据库信息缓存，部分配置数据长时间不变的在redis进行缓存，缓存部分对象，
     * hash存储 key：id value：data
     * key：chatdbcache_${tablename}
     */
    public static final String chatdatabaseCache = "chatdbcache_";
    /**
     * 公司自动分配策略
     * hash保存，可单独设置某一个分组的分配规则
     */
    public static final String autoChatPolicy = "companyAutoChatPolicy";

    /**
     * 公司客服登陆顺序保存，用于轮流分配对话的自动分配策略
     * list保存：在客服退出时移除队列上线时进入对话（只有有接待能力和对话权限以及参与自动分配的客服会到此队列中来，其他的分配策略一样）
     * value:staffId
     * key:avgAutoChatStaffList_${companyId}
     */
    public static final String avgAutoChatStaffList = "avgAutoChatStaffList";
    /**
     * 公司客服目前接待能力权重保存，用于根据接待能力和空闲状态来进行自动分配
     * sortSet:每次选择接待对话权重最高的客服进行自动分配
     * key:weightAutoChatStaffSet_${companyId}
     */
    public static final String weightAutoChatStaffSet = "weightAutoChatStaffSet";

    /**
     * 当前可接待对话有效对话量权重列表，如果公司启用或者公司内分组启用了此规则会存在此报表
     */
    public static final String avgDailyEffectiveAutoChatStaffSet = "avgDEAutoChatStaffSet";

    /**
     * 当前可接待对话量权重列表，如果公司启用或者公司内分组启用了此规则会存在此报表
     * 按照当日接待对话量最少的客服进行分配
     */
    public static final String avgDailyAutoChatStaffSet = "avgDAutoChatStaffSet";

    /**
     * 公司客服目前接待能力权重保存，用于根据接待能力和空闲状态以及顺序来进行自动分配 排在最前面的优先接待访客
     * sortSet:每次选择接待对话权重最高的客服进行自动分配
     * key:fOAutoChatStaffSet_${companyId}
     */
    public static final String fixOrderAutoChatStaffSet = "fOAutoChatStaffSet";

    /**
     * 按照指定的顺序进行轮流分配
     */
    public static final String orderAvgAutoChatStaffSet = "OavgAutoChatStaffSet";

    /**
     * 绝对按照顺序进行分配，只有前面的客服接待满以后才能给其他客服进行分配
     * sortSet:每次选择接待对话权重最高的客服进行自动分配
     * key:ffOAutoChatStaffSet_${companyId}
     */
    public static final String fullFixOrderAutoChatStaffSet = "ffOAutoChatStaffSet";

    /**
     * 按照指定顺序轮流分配，有新客服登陆也不改变分配顺序
     */
    public static final String orderAutoChatStaffSet = "orderAutoChatStaffSet";

    /**
     * 记录按照指定顺序轮流分配的客服ID
     */
    public static final String orderAutoChatStaffIndex = "orderAutoChatStaffIndex";

    /**
     * 当日客服有效对话接待量维护map
     * hashmap
     * key:staffEffectiveChatMap_${companyId}_${date}
     */
    public static final String staffEffectiveChatMap = "staffEffectiveChatMap";


    /**
     * 当日客服对话接待量维护map
     * hashmap
     * key:staffEffectiveChatMap_${companyId}_${date}
     */
    public static final String staffChatNumberMap = "staffChatNumberMap";
    /**
     * 公司客服对话相关信息维护记录客服当前的对话情况以及对话的接待能力，是否参与自动分配等，
     * 以及上次接通对话的时间
     * hash存储：key：staffid value:staffchatinfo
     * key:staffschatinfo_${companyId}
     */
    public static final String staffsChatInfo = "staffschatinfo";

    /**
     * 记录公司客服离线消息的访客数量
     */
    public static final String staffsOfflineMsgInfo = "staffsOfflineMsgInfo";
    /**
     * 访客等待接通对话队列,先进先出的策略对其进行分配
     * list存储
     * key:waitingToChatList_${companyId} value:${visitorId}
     */
    public static final String waitingToChatList = "waitingToChatList";
    /**
     * 阻止的session在一定时间内禁止握手
     */
    public static final String forbidSessionIdPrefix = "forbidSession";
    /**
     * 阻止一个client在一定时间内禁止握手
     */
    public static final String forbidCookieIdPrefix = "forbidCookie";
    /**
     * 公司相关配置缓存列表，包括对话窗口配置，防刷配置，自动分配配置，留言配置，等等
     * hash存储，其他的配置都通过自己的key进行设置
     */
    public static final String companyChatConfig = "companyChatConfig";

    /**
     * 公司相关配置缓存列表，包括对话窗口配置，防刷配置，自动分配配置，留言配置，等等
     * hash存储，其他的配置都通过自己的key进行设置
     */
    public static final String companyWordConfig = "companyWordConfig";

    /**
     * kafka消息由单独线程发送，存入到redis中保存数据
     */
    public static final String kafkaDataRedisKey = "kafkaRedisKey_data";

    /**
     * 保存所有chat服务器oortUrl_visitor地址
     */
    public static final String cometdServerVisitorMapKey = "cometdServerVisitorMapKey";

    /**
     * 批量执行数据库报错map
     */
    public static final String batchDatabaseErrorMap = "batchDatabaseErrorMap";

    //    /**
//     * 访客浏览轨迹i开列表 保存某个访客的浏览离开消息
//     set类型
//     key:visitorTrackLeaveSet_${companyId}_${visitorId}
//
//     */
//    public static final String visitorTrackLeaveSet = "visitorTrackLeaveSet_";
//    public static String getVisitorTrackLeaveSetKey(long companyId,String visitorId) {
//        return new StringBuffer().append(chatKeysPrefix).append(visitorTrackLeaveSet).
//                append(companyId).append("_").append(visitorId).toString();
//
//    }
    /*
    在访客对话需要验证码的时候，新的窗口打开的验证码配置要和之前保持一致，之前如果出现了验证码则本次会话一直出现
     */
    public static final String visitorChatCaptOpen = "visitorChatCaptOpen";
    /**
     * 上传文件后准备发送的图片token保存key
     */
    public static final String chatPreSendImageMsgToken = "chatPreSendImageMsgToken";
    /**
     * chat相关信息存储
     * hash存储  key:${talkid} value:chatextinfomsg
     */
    public static final String chatExtInfo = "chatExtInfo";

    public static final String chatButtonInfo = "chatButtonInfo";

    public static final String inviteBoxInfo = "inviteBoxInfo";

    public static final String chatBoxInfo = "chatBoxInfo";

    public static final String chatStyleWords = "chatStyleWords";

    public static final String visitorHistoryTrack = "visitorHistoryTrack";

    public static final String chatStyleDefaultValues = "chatStyleDefaultValues";

    public static final String visitorRouteOgnlExp = "visitorRouteOgnlExp";

    public static final String wechatRouteOgnlExp = "wechatRouteOgnlExp";

    public static final String crmContactsCache = "crmContactsCache";

    public static final String leaveWordInfo = "leaveWordInfo";

    public static final String bookingInfoTemplate = "bookingInfoTemplate";

    public static final String mostBookingInfo = "mostBookingInfo";

    public static final String chatInfoQueryTemplate = "chatInfoQueryTemplate";

    public static final String companyInfo = "companyInfo";

    public static final String profileStaffInfo = "profileStaffInfo";

    public static final String companyTreeData = "companyTreeData";

    public static final String focusVisitorInfoList = "focusVisitorInfoList";

    public static final String visitorTimeout = "visitorTimeout";

    public static final String wechatTimeout = "wechatTimeout";

    public static final String yichatUserMap = "yichatUserMap";

    public static final String staffConfig = "staffConfig";

    public static final String ipBindingConfig = "ipBindingConfig";

    public static final String macBindingConfig = "macBindingConfig";

    public static final String departmentStaffIdList = "departmentStaffIdList";

    public static final String staffIdListWithDepartmentStaffId = "staffIdListWithDepartmentStaffId";

    public static final String autoEstimageOgnlExp = "autoEstimageOgnlExp";
    /**
     * 按天保存某个客户每一天的访客数量信息，没产生一个访客 一个对话 一个留言 一个客户信息 对其进行数字递增操作  第二天对其进行保存操作
     * hash结构
     * key:count指标 详见DailyCountKey value:count数量 为空则表示为0
     */
    public static final String companyDailyData = "companyDailyData";

    public static final String staffDailyData = "staffDailyData";

    /**
     * 每日登陆的客服列表，按照公司来存，每天的凌晨12点半统计前一日的登陆客服数量 并将现在在线的客服纳入到今日的统计set中，方便以后
     * 按照客服天的计算单位来进行收费
     * SET结构保存当日登陆过的客服ID
     */
    public static final String dailyStaffLoginSet = "dailyStaffLoginSet";

    /**
     * 记录了每日数据的公司ID列表，在任务调度的时候通过此列表进行数据归档，然后删除三天前的数据
     */
    public static final String dailyDataCompanySet = "dailyDataCompanySet";

    /**
     * echat日常指标数据 每日凌晨统计，保存近30天的数据 进行对比
     * key:echatDailyData_${date} value:EchatDailyData
     */
    public static final String echatDailyData = "echatDailyData";

    public static final String valiateCompanyMap = "valiateCompanyMap";

    /*
     * 服务器在线状态统计，用于监控服务器的负载
     *hash保存
     * */
    public static final String onLineDataMap = "onlinedm";

    /**
     * 保存最大的cookieid
     */
    public static final String maxCookieId = "maxCookieId";

    /**
     * 保存最大的msgid
     */
    public static final String maxMsgId = "maxMsgId";

    public static final String newVisitorFlag = "newVisitorFlag";

    /**
     * 客户可用坐席数量缓存，每天只取一次，在后台修改了客户的坐席数量后刷新或者删除此key来达到更新的目的
     * 缓存24小时会有一定的误差但不影响
     */
    public static final String companySeatNumber = "companySeatNumber";

    /**
     * 公司未处理工单记录
     */
    public static final String companyUnDisposeJobMap = "companyUnDisposeJobMap";

    /**
     * 离线消息配置
     */
    public static final String offlineMsgConfigMap = "offlineMsgConfigMap";

    /**
     * 客服的临时消息列表，在服务器重启的和连接成功的过程中保存临时信息到redis
     * list
     */
    public static final String staffTmpMsgQueue = "stafftmq";

    /**
     * 在服务器重启的时候将客服的接收消息标示放到redis，在重连成功的期间如果有新消息接入则缓存到redis
     * hashmap
     * key:staffsetiuser id
     */
    public static final String staffTmpReceiveMsgToRedis = "stafftrmtr";

    /**
     * 在服务器关闭时将当前服务器中登录的客服订阅的广播频道关系设置到redis中，在其他服务器广播时将消息收入redis
     * hashmap
     */
    public static final String staffBoradChannelRelationWhenRestart = "staffbcrwr";

    /**
     * 设置服务器的重启状态，重启造成的cometd集群界面丢失 不做报警
     */
    public static final String serverRestartingStatus = "restart";

    /**
     * 设置公司的路由和部门的关系
     * hashmap
     * key:routeid
     * value:逗号分割的部门列表
     */
    public static final String routeDepartmentRef = "routedepmap";

    /**
     * 设置公司路由到全部人员的路由id的列表
     * string类型 value为都好分割的路由到所有人员的路由id
     */
    public static final String toAllDepRouteIds = "toAllDepRouteIds";

    /**
     * hash结构存储 设置了特定domain的信息
     * key：公司ID value：visitorsepcialdomain类的json
     */
    public static final String specialDomainMap = "specialDomainMap";

    /**
     * 某个部门的对话客服的状态
     * hash结构
     * key：depid
     * value：1：有对话客服 其他：无对话客服
     */
    public static final String departmentChatStaffStatus = "departmentCSS";

    /**
     * 设置对话验证码的缓存，因为访客可能打开多个页面所以可以在不同的页面输入验证码通过验证
     */
    public static final String chatCaptChaToken = "chatCaptChaToken";

    public static String getChatCaptChaTokenKey(long companyId, String visitorId) {
        return new StringBuffer(chatKeysPrefix).append(chatCaptChaToken).append(keySplit).append(companyId).append(keySplit).append(visitorId).toString();

    }

    public static String getToAllDepRouteIdsKey(long companyId) {
        return new StringBuffer(chatKeysPrefix).append(toAllDepRouteIds).append(keySplit).append(companyId).toString();
    }

    public static String getSpecialDomainMapKey() {
        return new StringBuffer(chatKeysPrefix).append(specialDomainMap).toString();
    }

    public static String getDepartmentChatStaffStatusKey(long companyId) {
        return new StringBuffer(chatKeysPrefix).append(departmentChatStaffStatus).append(keySplit).append(companyId).toString();
    }

    public static String getCompanyRouteDepartmentRefKey(long companyId) {
        return new StringBuffer(chatKeysPrefix).append(routeDepartmentRef).append(keySplit).append(companyId).toString();
    }

    public static String getServerRestartingKey(String cometdUrl) {
        return new StringBuffer(chatKeysPrefix).append(serverRestartingStatus).append(keySplit).append(cometdUrl).toString();
    }

    public static String getStaffBroadChannelRelationKey(String channel) {
        return new StringBuffer(chatKeysPrefix).append(staffBoradChannelRelationWhenRestart).append(keySplit).append(channel).toString();
    }

    public static String getStaffTmpReceiveMsgToRedisKey() {
        return new StringBuffer(chatKeysPrefix).append(staffTmpReceiveMsgToRedis).toString();
    }


    public static String getStaffTempMsgQueueKey(long companyId, long staffId) {
        return new StringBuffer(chatKeysPrefix).append(staffTmpMsgQueue).append(keySplit).append(companyId).append(keySplit).append(staffId).toString();
    }

    public static String getCompanySeatNumberKey(long companyId) {
        return new StringBuffer(chatKeysPrefix).append(companySeatNumber).append(keySplit).append(companyId).toString();
    }

    /**
     * 存储访客端sdk接入的token和公司的对应关系
     */
    public static final String sdkAppInfoMap = "sdkAppInfoMap";

    public static String getSDKAppInfoMapKey() {
        return new StringBuffer(chatKeysPrefix).append(sdkAppInfoMap).toString();
    }

    /**
     * @param visitorId
     * @return 新产生cookieid的时候设置flag 用来表示此访客是新访客不用从数据库读取信息
     */
    public static String getNewVisitorFlagKey(String visitorId) {
        return new StringBuffer(chatKeysPrefix).append(newVisitorFlag).append(keySplit).append(visitorId).toString();
    }


    /**
     * @param serverGroup
     * @return 根据不同的服务器组获取不同的cookieID保存key，后期可使用同一个redis提供给
     * 不同的服务器群组使用目前叫echat，后期如果根据不同的国家有不同的访客ID，那么可使用国家名来或者州名来定义
     */
    public static String getMaxCookieIdKey(String serverGroup) {
        return new StringBuffer(chatKeysPrefix).append(serverGroup).append(keySplit).append(maxCookieId).toString();
    }

    /**
     * @param companyId
     * @return 获取此公司最大的消息id，用于记录消息的顺序以及读取状态等
     */
    public static String getMaxMsgIdKey(Long companyId) {
        return new StringBuffer(chatKeysPrefix).append(keySplit).append(maxMsgId).append(keySplit).append(companyId).toString();
    }

    public static String getOnLineDataMapKey() {
        return new StringBuffer(chatKeysPrefix).append(onLineDataMap).toString();
    }


    public static String getValidateCompayMapKey() {
        return new StringBuffer(chatKeysPrefix).append(valiateCompanyMap).toString();
    }
//    public static final String dailyDataChange

    public static String getDailyDataCompanySetKey() {
        return getDailyDataCompanySetKey(DateFormatUtil.getTodayyyyyMMdd());
    }

    public static String getDailyDataCompanySetKey(String date) {
        return new StringBuffer(chatKeysPrefix).append(dailyDataCompanySet).append(keySplit).append(date).toString();
    }


    public static String getDailyStaffLoginSetKey(long companyId) {
        return getDailyStaffLoginSetKey(companyId, DateFormatUtil.getTodayyyyyMMdd());
    }

    public static String getDailyStaffLoginSetKey(long companyId, String date) {
        return new StringBuffer(chatKeysPrefix).append(dailyStaffLoginSet).append(keySplit).append(companyId).append(keySplit).append(DateFormatUtil.getTodayyyyyMMdd()).toString();
    }


    /**
     * 每日统计数量报表 指标
     */
    public static interface DailyCountKey {
        public static final String maxLogins = "maxLogins";//最大登陆客服数量
        public static final String staffLogins = "staffLogins";//当日登陆的客服去重数量
        public static final String vCount = "vCount";//来访访客数量
        public static final String svCount = "svCount";//搜索来访访客数量
        public static final String newvCount = "newvCount";//新访客数量
        public static final String newsvCount = "newsvCount";//新搜索来访访客数量
        public static final String vCountNologin = "vCountNologin";//离线访客数量
        public static final String svCountNologin = "svCountNologin";//离线访客搜索来源数量
        public static final String newvCountNologin = "newvCountNologin";//新访客来访数量（客服离线）
        public static final String newsvCountNologin = "newsvCountNologin";//搜索来源新访客数量（客服离线）
        public static final String cCount = "cCount";//产生对话数量
        public static final String scCount = "scCount";//搜索对话数量
        public static final String newcCount = "newcCount";//新访客对话数量
        public static final String newscCount = "newscCount";//新访客搜索对话数量
        public static final String bCount = "bCount";//日当预约数量
        public static final String sbCount = "sbCount";//搜索来源预约数量
        public static final String newbCount = "newbCount";//新访客预约数量
        public static final String newsbCount = "newsbCount";//新访客搜索预约数量
        public static final String crmCount = "crmCount";//当日客户信息创建数量
        public static final String lCount = "lCount";//留言数量(总量）
        public static final String slCount = "slCount";//索搜留言数量
        public static final String lCountNologin = "lCountNologin";//线离留言数量
        public static final String slCountNologin = "slCountNologin";//搜索留言数量-客服离线
        public static final String clCount = "clCount";//访客点击对话图标数量
        public static final String sclCount = "sclCount";//搜索来源点击对话图标数量
        public static final String newclCount = "newclCount";//新访客点击对话图标数量
        public static final String newsclCount = "newsclCount";//新访客搜索来源点击对话图标数量
        public static final String clCountNologin = "clCountNologin";//访客离线点击数量
        public static final String sclCountNologin = "sclCountNologin";//搜索来源访客点击数量（客服离线）
        public static final String newclCountNologin = "newclCountNologin";//访客新点击数量（客服离线）
        public static final String newsclCountNologin = "newsclCountNologin";//新访客搜索来源点击数量（客服离线）
    }

    public static interface OnlineDataKey {
        public static final String visitorCount = "visitorCount";
        public static final String waitingChatCount = "waitingChatCount";
        public static final String chatingCount = "chatingCount";
        public static final String staffCount = "staffCount";
    }

    /**
     * 客服每日统计
     */
    public static interface StaffDailyCountKey {
        public static final String bCount = "bCount";//日当预约数量
    }

    public static String getStaffDailyDataKey(long companyId, long staffId, String date) {
        return new StringBuffer(chatKeysPrefix).append(staffDailyData).append(keySplit).append(companyId).append(keySplit).append(staffId).append(keySplit).append(date).toString();
    }

    public static String getCompanyDailyDataKey(long companyId) {
        return getCompanyDailyDataKey(companyId, DateFormatUtil.getTodayyyyyMMdd());
    }

    public static String getCompanyDailyDataKey(long companyId, String date) {
        return new StringBuffer(chatKeysPrefix).append(companyDailyData).append(keySplit).append(companyId).append(keySplit).append(date).toString();
    }

    public static String getEchatDailyDataKey(String date) {
        return new StringBuffer(chatKeysPrefix).append(echatDailyData).append(keySplit).append(date).toString();
    }

    public static String getStaffEffectiveChatMapKey(long companyId) {
        return getStaffEffectiveChatMapKey(companyId, DateFormatUtil.getTodayyyyyMMdd());
    }

    public static String getStaffEffectiveChatMapKey(long companyId, String date) {
        return new StringBuffer(chatKeysPrefix).append(staffEffectiveChatMap).append(keySplit).append(companyId).append(keySplit).append(date).toString();
    }

    public static String getStaffChatNumberMapKey(long companyId) {
        return getStaffChatNumberMapKey(companyId, DateFormatUtil.getTodayyyyyMMdd());
    }

    public static String getStaffChatNumberMapKey(long companyId, String date) {
        return new StringBuffer(chatKeysPrefix).append(staffChatNumberMap).append(keySplit).append(companyId).append(keySplit).append(date).toString();
    }

    /**
     * @param companyId
     * @return 获取部门状态缓存key
     */
    public static String getCompanyDepartmentStatusKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(departmentStatus).
                append(companyId).toString();
    }

    /**
     * @param companyId
     * @return 获取路由状态缓存key
     */
    public static String getCompanyRouteStatusKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(routeStatus).
                append(companyId).toString();
    }

    /**
     * @param companyId
     * @param visitorId
     * @return 获取缓存访客历史浏览轨迹的消息
     * 数据类型为hash
     * 保存每次的浏览轨迹
     */
    public static String getVisitorHistoryTrackKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(visitorHistoryTrack).
                append(companyId).append(keySplit).append(visitorId).toString();
    }

    public static String getRedisKey(String key) {
        return chatKeysPrefix + key;
    }

    public static String getSynchronizedKey(long companyId) {
        return new StringBuffer().append(commonKeysPrefix).append(synchronizedFlag).append(companyId).toString();
    }

    public static String getRouteHotTopicsKey(long companyId, String dimension) {
        return new StringBuffer().append(chatKeysPrefix).append(routeHotTopics).append(companyId).append(keySplit).append(dimension).toString();
    }

    public static String getStaffInfoKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(i18nStaffInfo).append(companyId).toString();
    }

    public static String getStaffExtInfoKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffExtInfo).append(companyId).toString();
    }

    public static String getStaffStatusKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffStatus).append(companyId).toString();
    }

    public static String getStaffLoginMediaKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffLoginMedia).append(companyId).toString();
    }

    public static String getRolePrivilegeKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(rolePrivilege).append(companyId).toString();
    }

    public static String getStaffRoleKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffRole).append(companyId).toString();
    }

    public static String getCompanyVersionRefKey() {
        return new StringBuffer().append(chatKeysPrefix).append(companyVersionRef).toString();
    }

    public static String getCompanyVersionExtRefKey() {
        return new StringBuffer().append(chatKeysPrefix).append(companyVersionExtRef).toString();
    }

    public static String getRobotVersionRefKey() {
        return new StringBuffer().append(chatKeysPrefix).append(robotVersionRef).toString();
    }

    public static String getVersionKey() {
        return new StringBuffer().append(chatKeysPrefix).append(version).toString();
    }

    public static String getStaffDepartmentRefKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffDepartment).append(companyId).toString();
    }

    public static String getStaffRouteRefKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffRoute).append(companyId).toString();
    }

    public static final String getStaffStatusTimeKey(long companyId, long staffId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffStatusTime).append(companyId).append(keySplit).append(staffId).toString();
    }

    public static final String getStaffLoginingStatusKey(long companyId, long staffId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffLoginingStatus).append(companyId).append(keySplit).append(staffId).toString();
    }

    public static final String getHttpSessionStaffInfoKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(httpSessionStaffInfo).append(companyId).toString();
    }

    public static String getCompanyChatMapKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyChatMap).append(companyId).toString();
    }

    @Deprecated
    public static String getCompanyOfflineMapKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyOfflineMap).append(companyId).toString();
    }

    public static String getCompanyOfflineV2MapKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyOfflineV2Map).append(companyId).toString();
    }

    public static String getCompanyOfflineV2HashKey(String visitorId, String routeId) {
        return new StringBuffer().append(visitorId).append(keySplit).append(routeId).toString();
    }

    public static String getCompanyVisitorMapKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyVisitorMap).append(companyId).toString();
    }

    public static String getCompanyBeInvitedMapKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyBeInvitedMap).append(companyId).toString();
    }

    public static String getCompanyBeInitiativeChatMapKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyBeInitiativeChatMap).append(companyId).toString();
    }

    public static String getStaffBeMonitoredSetKey(long companyId, long staffId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffBeMonitoredSet).
                append(companyId).append(keySplit).append(staffId).toString();

    }

    public static String getStaffMonitorSetKey(long companyId, long staffId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffMonitorSet).
                append(companyId).append(keySplit).append(staffId).toString();

    }

    public static String getVisitorTrackListKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(visitorTrackList).
                append(companyId).append(keySplit).append(visitorId).toString();

    }

    public static String getChatDetailListKey(long companyId, String visitorId, String talkId) {
        return new StringBuffer().append(chatKeysPrefix).append(chatDetailList).
                append(companyId).append(keySplit).append(visitorId).append(keySplit).append(talkId).toString();

    }

    public static String getUnreadChatDetailListKey(long companyId, String visitorId, String talkId) {
        return new StringBuffer().append(chatKeysPrefix).append(unreadChatDetailList).
                append(companyId).append(keySplit).append(visitorId).append(keySplit).append(talkId).toString();
    }

    public static String getChatInfoArchiveKey(long companyId, String visitorId, String talkId) {
        return new StringBuffer().append(chatKeysPrefix).append(chatInfoArchive).
                append(companyId).append(keySplit).append(visitorId).append(keySplit).append(talkId).toString();
    }

    public static String getChatDetailTranslationListKey(long companyId, String visitorId, String talkIk) {
        return new StringBuffer().append(chatKeysPrefix).append(chatDetailTranslationList).append(companyId).append(keySplit)
                .append(visitorId).append(keySplit).append(talkIk).toString();
    }

    public static String getOfflineDetailListKey(long companyId, String visitorId, String talkId) {
        return new StringBuffer().append(chatKeysPrefix).append(offlineDetailList).
                append(companyId).append(keySplit).append(visitorId).append(keySplit).append(talkId).toString();
    }

    public static String getOfflineDetailTranslationListKey(long companyId, String visitorId, String talkId) {
        return new StringBuffer().append(chatKeysPrefix).append(offlineDetailTranslationList)
                .append(companyId).append(keySplit).append(visitorId).append(keySplit).append(talkId).toString();
    }

    public static String getPushInfoSetKey(long companyId, String visitorId, String talkId) {
        return new StringBuffer().append(chatKeysPrefix).append(pushInfoSet).
                append(companyId).append(keySplit).append(visitorId).append(keySplit).append(talkId).toString();
    }

    public static String getRobotDetailListKey(long companyId, String visitorId, String talkId) {
        return new StringBuffer().append(chatKeysPrefix).append(robotDetailList).
                append(companyId).append(keySplit).append(visitorId).append(keySplit).append(talkId).toString();
    }

    public static String getVisitorSessionMapKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(visitorSessionMap).
                append(companyId).append(keySplit).append(visitorId).toString();
    }

    public static String getVisitorDetailCacheKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(visitorDetailCache).
                append(companyId).append(keySplit).append(visitorId).toString();
    }

    public static String getVisitorBlackListIpCacheKey(long companyId, Long ip) {
        return new StringBuffer().append(chatKeysPrefix).append(visitorBlackListIpCache).
                append(companyId).append(keySplit).append(ip).toString();
    }

    public static String getVisitorBlackListIdCacheKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(visitorBlackListIdCache).
                append(companyId).append(keySplit).append(visitorId).toString();
    }

    public static String getChaterSessionMapKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(chaterSessionMap).
                append(companyId).append(keySplit).append(visitorId).toString();
    }

    public static String getOfflineSessionMapKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(offlineSessionMap).
                append(companyId).append(keySplit).append(visitorId).toString();
    }

    public static String getChatCloseReasonCacheKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(chatCloseReasonCache).
                append(companyId).append(keySplit).append(visitorId).toString();
    }

    public static String getChatDataBaseCacheKey(String tableName) {
        return new StringBuffer().append(chatKeysPrefix).append(chatdatabaseCache).
                append(tableName).toString();
    }

    public static String getCompanyAutoChatPolicyKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(autoChatPolicy).append(keySplit)
                .append(companyId).toString();
    }

    public static String getAvgAutoChatStaffListKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(avgAutoChatStaffList).append(keySplit)
                .append(companyId).toString();
    }

    public static String getWeightAutoChatStaffSetKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(weightAutoChatStaffSet).append(keySplit)
                .append(companyId).toString();
    }


    public static String getAvgDailyEffectiveAutoChatStaffSetKey(long companyId) {
        return getAvgDailyEffectiveAutoChatStaffSetKey(companyId, DateFormatUtil.getTodayyyyyMMdd());
    }

    public static String getAvgDailyEffectiveAutoChatStaffSetKey(long companyId, String date) {
        return new StringBuffer().append(chatKeysPrefix).append(avgDailyEffectiveAutoChatStaffSet).append(keySplit)
                .append(companyId).append(keySplit).append(date).toString();
    }

    public static String getAvgDailyAutoChatStaffSetKey(long companyId) {

        return getAvgDailyAutoChatStaffSetKey(companyId, DateFormatUtil.getTodayyyyyMMdd());
    }

    public static String getAvgDailyAutoChatStaffSetKey(long companyId, String date) {
        return new StringBuffer().append(chatKeysPrefix).append(avgDailyAutoChatStaffSet).append(keySplit)
                .append(companyId).append(keySplit).append(date).toString();
    }

    public static String getFixOrderAutoChatStaffSetKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(fixOrderAutoChatStaffSet).append(keySplit)
                .append(companyId).toString();
    }


    public static String getDepartmentAvgAutoChatStaffListKey(long companyId, String departmentId) {
        return new StringBuffer().append(chatKeysPrefix).append(avgAutoChatStaffList).append(keySplit)
                .append(companyId).append(keySplit).append(departmentId).toString();
    }

    public static String getDepartmentWeightAutoChatStaffSetKey(long companyId, String departmentId) {
        return new StringBuffer().append(chatKeysPrefix).append(weightAutoChatStaffSet).append(keySplit)
                .append(companyId).append(keySplit).append(departmentId).toString();
    }

    public static String getDepartmentFixOrderAutoChatStaffSetKey(long companyId, String departmentId) {
        if (StringUtil.isEmpty(departmentId)) {
            return getFixOrderAutoChatStaffSetKey(companyId);
        }
        return new StringBuffer().append(chatKeysPrefix).append(fixOrderAutoChatStaffSet).append(keySplit)
                .append(companyId).append(keySplit).append(departmentId).toString();
    }

    public static String getFullFixOrderAutoChatStaffSetKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(fullFixOrderAutoChatStaffSet).append(keySplit)
                .append(companyId).toString();
    }

    public static String getDepartmentFullFixOrderAutoChatStaffSetKey(long companyId, String departmentId) {
        if (StringUtil.isEmpty(departmentId)) {
            return getFullFixOrderAutoChatStaffSetKey(companyId);
        }
        return new StringBuffer().append(chatKeysPrefix).append(fullFixOrderAutoChatStaffSet).append(keySplit)
                .append(companyId).append(keySplit).append(departmentId).toString();
    }

    public static String getOrderAvgAutoChatStaffSetKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(orderAvgAutoChatStaffSet).append(keySplit)
                .append(companyId).toString();
    }

    public static String getDepartmentOrderAvgAutoChatStaffSetKey(long companyId, String departmentId) {
        if (StringUtil.isEmpty(departmentId)) {
            return getOrderAvgAutoChatStaffSetKey(companyId);
        }
        return new StringBuffer().append(chatKeysPrefix).append(orderAvgAutoChatStaffSet).append(keySplit)
                .append(companyId).append(keySplit).append(departmentId).toString();
    }

    public static String getOrderAutoChatStaffSetKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(orderAutoChatStaffSet).append(keySplit)
                .append(companyId).toString();
    }

    public static String getDepartmentOrderAutoChatStaffSetKey(long companyId, String departmentId) {
        if (StringUtil.isEmpty(departmentId)) {
            return getOrderAutoChatStaffSetKey(companyId);
        }
        return new StringBuffer().append(chatKeysPrefix).append(orderAutoChatStaffSet).append(keySplit)
                .append(companyId).append(keySplit).append(departmentId).toString();
    }

    public static String getOrderAutoChatStaffIndexKey() {
        return new StringBuffer().append(chatKeysPrefix).append(orderAutoChatStaffIndex).toString();
    }

    public static String getOrderAutoChatStaffIndexHashKey(long companyId, String departmentId) {
        if (StringUtil.isEmpty(departmentId)) {
            return String.valueOf(companyId);
        } else {
            return new StringBuffer().append(companyId).append(keySplit).append(departmentId).toString();
        }
    }

    public static final String getStaffschatInfoKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffsChatInfo).append(keySplit)
                .append(companyId).toString();
    }

    public static final String getStaffsOfflineMsgInfoKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffsOfflineMsgInfo).append(keySplit)
                .append(companyId).toString();
    }

    public static String getWaitingToChatListKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(waitingToChatList).append(keySplit)
                .append(companyId).toString();
    }

    /**
     * @param companyId
     * @param routeId
     * @return 获取指定路由的待分配列表
     */
    public static String getWaitingToChatListKey(long companyId, String routeId) {
        return new StringBuffer().append(chatKeysPrefix).append(waitingToChatList).append(keySplit)
                .append(companyId).append(keySplit).append(routeId).toString();
    }

    public static String getCompanyChatConfigKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyChatConfig).append(keySplit)
                .append(companyId).toString();
    }

    public static String getCompanyWordConfigKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyWordConfig).append(keySplit)
                .append(companyId).toString();
    }

    public static final String getVisitorChatCaptTokenKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(visitorChatCaptOpen).append(keySplit)
                .append(companyId).append(keySplit).append(visitorId).toString();
    }

    public static String getChatPreSendImageMsgTokenKey() {
        return new StringBuffer().append(chatKeysPrefix).append(chatPreSendImageMsgToken).toString();
    }

    public static String getChatExtInfoKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(chatExtInfo).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileChatButtonInfoKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(chatButtonInfo).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileInviteBoxInfoKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(inviteBoxInfo).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileChatBoxInfoKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(chatBoxInfo).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileChatStyleWordsKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(chatStyleWords).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileDefaulValuesKey() {
        return new StringBuffer().append(chatProfileKeysPrefix).append(chatStyleDefaultValues).toString();
    }

    public static String getChatProfileVisitorRouteOgnlExpKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(visitorRouteOgnlExp).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileAutoEstimateOgnlExpKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(autoEstimageOgnlExp).append(keySplit).append(companyId).toString();
    }

    public static final String mulWechatRouteOgnlExp = "mulWechatRouteOgnlExp";

    public static String getChatProfileWechatRouteOgnlExpKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(mulWechatRouteOgnlExp).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileWechatRouteOgnlExpKey(long companyId, String wechatUsername) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(mulWechatRouteOgnlExp).append(keySplit)
                .append(companyId).append(keySplit).append(wechatUsername).toString();
    }

    public static String getCrmContactsCacheKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(crmContactsCache).append(keySplit).append(companyId).append(keySplit).append(visitorId).toString();
    }

    public static String getChatProfileLeaveWordInfoKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(leaveWordInfo).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileBookingInfoTemplateKey() {
        return new StringBuffer().append(chatProfileKeysPrefix).append(bookingInfoTemplate).toString();
    }

    public static String getChatMostBookingInfoKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(mostBookingInfo).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileChatInfoQueryTemplateKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(chatInfoQueryTemplate).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileCompanyInfoKey() {
        return new StringBuffer().append(chatProfileKeysPrefix).append(companyInfo).toString();
    }

    public static String getChatProfileStaffInfoKey(long companyId) {
      return new StringBuffer().append(chatProfileKeysPrefix).append(profileStaffInfo).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileCompanyTreeDataKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(companyTreeData).append("_").append(companyId).toString();
    }

    public static String getChatFocusVisitorInfoListKey(long companyId, String date) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(focusVisitorInfoList).append("_").append(companyId).append("_").append(date).toString();
    }

    public static String getChatProfileVisitorTimeoutKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(visitorTimeout).append(keySplit).append(companyId).toString();
    }

    public static String getChatProfileWechatTimeoutKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(wechatTimeout).append(keySplit).append(companyId).toString();
    }

    public static String getCompanyChatVisitorUnSendMapKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(companyChatVisitorUnSendMap).append(keySplit).append(companyId).toString();

    }

    public static String getCompanyChatStaffUnSendMapKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(companyChatStaffUnSendMap).append(keySplit).append(companyId).toString();

    }

    public static String getCompanyChatBusyAutoReplyMapKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(companyChatBusyAutoReplyMap).append(keySplit).append(companyId).toString();
    }

    public static String getCompanyChatStaffUnSendMapHkey(long staffId, String visitorId) {
        return new StringBuffer().append(staffId).append(keySplit).append(visitorId).toString();
    }

    public static String getDepartmentStaffIdListKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(departmentStaffIdList).append(keySplit).append(companyId).toString();
    }

    public static String getCompanyChatStaffUnSendMapStaffId(String hkey) {
        if (StringUtil.isNotEmpty(hkey)) {
            String[] stringArr = hkey.split(keySplit);
            if (stringArr != null && stringArr.length >= 2) {
                return stringArr[0];
            }
        }
        return null;
    }

    public static String getCompanyChatStaffUnSendMapVisitorId(String hkey) {
        if (StringUtil.isNotEmpty(hkey)) {
            String[] stringArr = hkey.split(keySplit);
            if (stringArr != null && stringArr.length >= 2) {
                return hkey.substring(hkey.indexOf(keySplit) + 1, hkey.length());
            }
        }
        return null;
    }

    public static String getChatProfileyichatUserMapKey() {
        return new StringBuffer().append(chatProfileKeysPrefix).append(yichatUserMap).toString();
    }

    public static String getChatStaffConfigKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffConfig).append(keySplit).append(companyId).toString();
    }

    public static String getChatStaffConfigHashKey(long staffId, String staffConfigKey) {
        return new StringBuffer().append(String.valueOf(staffId)).append(keySplit).append(staffConfigKey).toString();
    }

    public static String getChatIpBindingConfigKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(ipBindingConfig).append(keySplit).append(companyId).toString();
    }

    public static String getChatMacBindingConfigKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(macBindingConfig).append(keySplit).append(companyId).toString();
    }

    public static String getStaffIdListWithDepartmentStaffIdKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(staffIdListWithDepartmentStaffId).append(keySplit).append(companyId).toString();
    }

    public static String getCompanyWechatAuthConfigKey(long companyId) {
        return new StringBuffer().append(wechatKeysPrefix).append(companyChatConfig).append(keySplit)
                .append(companyId).toString();
    }

    public static interface StaffStatusTime {
        public static final String changeTime = "changeTime";//状态初始化或者改变的时间
        public static final String signonLogId = "signonLogId";
        public static final String signonLoginTime = "signonLoginTime";
        public static final String lastSignonLogDetailId = "lastSignonLogDetailId";//上一次事件id
    }

    public static interface CompanyConfigKeys {
        public static final String departmentIds = "departmentIds";
        public static final String departmentListMsg = "departmentListMsg";
        public static final String autoChatPolicy = "autoChatPolicy";
        public static final String autoChatStaffFixOrder = "autoChatStaffFixOrder";
        public static final String chatWindowCaptChaConfig = "chatWindowCaptChaConfig";
        public static final String chatLevelConfig = "chatLevelConfig";
        public static final String visitorTagConfig = "visitorTagConfig";
        public static final String medicalAdToken = "medicalAdToken";
        public static final String companyFaqVersion = "companyFaqVersion";
        public static final String autoChatLastStaff = "autoChatLastStaff";
        public static final String ipBindingEnable = "ipBindingEnable";
        public static final String macBindingEnable = "macBindingEnable";
        public static final String staffUnSendConfig = "staffUnSendConfig";
        public static final String wechatAutoReply = "wechatAutoReply";
        public static final String specialDomain = "specialDomain";
        public static final String evaluateConfig = "evaluateConfig";
        public static final String busyAutoReply = "busyAutoReply";
        public static final String wechatAuthInfo = "wechatAuthInfo";
        public static final String companyTrackConfig = "companyTrackConfig";
        public static final String responseInTimeConfig = "responseInTimeConfig";
        public static final String monitorVisitorEnable = "monitorVisitorEnable";
        public static final String saveTrackFootprintEnable = "saveTrackFootprintEnable";
        public static final String staffCompanyWordConfig = "staffCompanyWordConfig";
        public static final String visitorCompanyWordConfig = "visitorCompanyWordConfig";
        public static final String companyWordEnable = "companyWordEnable";
        public static final String companyOtherSetting = "companyOtherSetting";
    }

    public static interface StaffConfigKeys {
        public static final String pcAutoReply = "pcAutoReply";//pc自动应答语
        public static final String mobileAutoReply = "mobileAutoReply";//手机自动应答语
        public static final String staffFaqVersion = "staffFaqVersion";
        public static final String staffUsedFaqVersion = "staffUsedFaqVersion";
        public static final String remindWayConfig = "remindWayConfig";//消息提醒方式配置
        public static final String wechatAutoReply = "wechatAutoReply";//微信自动应答语
        public static final String bookingDoctor = "bookingDoctor";//个人常用预约专家
        public static final String bookingNumber = "bookingNumber";//个人常用预约号码
        public static final String shortcutKey = "shortcutKey";//快捷键配置
    }

    public static interface I18nConfigKeys {
        public static final String overTimeAutoReply = "overTimeAutoReply";//客服超时自动回复
    }

    /**
     * 每台服务器根据链接者的属性来保存session方便统计各类型客户端的在线数量
     */
    public static interface CometdUserType {
        public static final String visitor = "visitor";
        public static final String chater = "chater";
        public static final String staff = "staff";
    }

    /**
     * @param server
     * @param type
     * @return 获取某个服务器的访客、对话、客服相对应的session维护map的key
     */
    public static String getCometdClientSessionMapKey(String server, String type) {
        return new StringBuffer(server).append(keySplit).append(type).toString();
    }

    /**
     * 获取批量执行数据库报错map的key
     *
     * @param topic
     * @param type
     * @return
     */
    public static String getBatchDatabaseErrorMapKey(String topic, String type) {
        return new StringBuffer(chatKeysPrefix).append(batchDatabaseErrorMap).append(keySplit)
                .append(topic).append(keySplit).append(type).toString();
    }


    /**
     * 获取离线消息配置维护map的key
     *
     * @return
     */
    public static String getOfflineMsgConfigMap() {
        return new StringBuffer(chatKeysPrefix).append(offlineMsgConfigMap).toString();
    }

    /**
     * 获取公司未处理工单记录map的key
     *
     * @param companyId
     * @param staffId
     * @return
     */
    public static String getCompanyUnDisposeJobMapKey(long companyId, long staffId) {
        return new StringBuffer(chatKeysPrefix).append(companyUnDisposeJobMap).append(keySplit).append(companyId).append(keySplit).append(staffId).toString();
    }


    /**
     * 微信访客排队位置
     */
    private static final String wechatWaitingPositionMap = "wechatWaitingPositionMap";

    public static String getWechatWaitingPositionMapMapKey(long companyId) {
        return new StringBuffer(chatKeysPrefix).append(wechatWaitingPositionMap).append(keySplit).append(companyId).toString();
    }

    /**
     * 监控关系map：a管理员查看b客服的c访客的对话信息，则记录a的staffId为hash的key，c的visitorId为hash的value
     */
    private static final String monitorRelationMap = "monitorRelationMap";

    public static String getChatMonitorRelationMapKey(long companyId) {
        return new StringBuffer(chatKeysPrefix).append(monitorRelationMap).append(keySplit).append(companyId).toString();
    }

    /**
     * 离线消息关系map：a客服点击b访客的离线消息，则记录a的staffId为hash的key，b的visitorId为hash的value
     */
    @Deprecated
    private static final String offlineMsgRelationMap = "offlineMsgRelationMap";

    @Deprecated
    public static String getChatOfflineMsgRelationMapKey(long companyId) {
        return new StringBuffer(chatKeysPrefix).append(offlineMsgRelationMap).append(keySplit).append(companyId).toString();
    }

    /**
     * 样式中心：满意度调查
     */
    public static final String evaluateInfo = "evaluateInfo";

    public static String getChatProfileEvaluateInfoKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(evaluateInfo).append(keySplit).append(companyId).toString();
    }

    /**
     * 样式中心：入口定制
     */
    public static final String entranceInfo = "entranceInfo";

    public static String getChatProfileEntranceInfoKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(entranceInfo).append(keySplit).append(companyId).toString();
    }

    /**
     * 自动分配：部门配对
     */
    public static final String companyAutoChatMatchDepartment = "companyAutoChatMatchDepartment";

    public static String getChatCompanyAutoChatMatchDepartmentKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyAutoChatMatchDepartment).append(keySplit).append(companyId).toString();
    }

    /**
     * 公司权限
     */
    public static final String companyPrivilegeMap = "companyPrivilegeMap";

    public static String getChatCompanyPrivilegeMapKey() {
        return new StringBuffer().append(chatKeysPrefix).append(companyPrivilegeMap).toString();
    }

    /**
     * 样式中心： 微信自动接入
     */
    public static final String wechatTrigger = "wechatTrigger";

    public static String getWechatTriggerInfoKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(wechatTrigger).append(keySplit).append(companyId).toString();
    }

    /**
     * 信任信息接口缓存
     */
    public static final String crmInterfaceConfig = "crmInterfaceConfig";

    public static String getChatCrmInterfaceConfigKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(crmInterfaceConfig).append(keySplit).append(companyId).toString();
    }

    /**
     * 获取服务器中的所有公司的id
     */
    public static final String getAllCompanies = "getAllCompanies";

    public static String getAllCompaniesKey() {
        return new StringBuffer().append(chatProfileKeysPrefix).append(getAllCompanies).toString();
    }

    /**
     * 获取公司报表定制计划任务
     */
    public static final String getAllCompanyDict = "getAllCompanyDict";

    public static String getAllCompanyDictKey() {
        return new StringBuffer().append(reportKeysPrefix).append(getAllCompanyDict).toString();
    }

    /**
     * 获取邮件excel附件地址
     *
     * @param dictId
     * @param type
     * @return
     */
    public static String getExcelUrlKey(String dictId, String type, String companyId) {
        return new StringBuffer(reportKeysPrefix).append(dictId).append(keySplit).append(companyId).append(keySplit).append(type).toString();
    }

    public static final String getExcelUrlKey = "getAllExcelUrl";

    /**
     * 获取附件地址mapkey
     *
     * @return
     */
    public static String getExcelUrlKey() {
        return new StringBuffer(reportKeysPrefix).append(getExcelUrlKey).toString();
    }

    /**
     * 微信公众账号授权信息
     */
    private static final String wechatAuthorizationMap = "wechatAuthorizationMap";

    public static String getWechatAuthorizationMapKey() {
        return new StringBuffer(ChatRedisKeys.wechatKeysPrefix).append(wechatAuthorizationMap).toString();
    }

    /**
     * 公司路由集合
     */
    public static final String visitorRouteMap = "visitorRouteMap";

    public static String getVisitorRouteMapKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(visitorRouteMap).append(keySplit).append(companyId).toString();
    }

    /**
     * 公司样式集合
     */
    public static final String chatStyleMap = "chatStyleMap";

    public static String getChatStyleMap(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(chatStyleMap).append(keySplit).append(companyId).toString();
    }

    /**
     * 公司部门集合
     */
    public static final String departmentMap = "departmentMap";

    public static String getDepartmentMap(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(departmentMap).append(keySplit).append(companyId).toString();
    }

    /**
     * 公司角色集合
     */
    public static final String staffRoleMap = "staffRoleMap";

    public static String getStaffRoleMapMap(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(staffRoleMap).append(keySplit).append(companyId).toString();
    }

    /**
     * 排班计划集合
     */
    public static final String schedulePlanMap = "schedulePlanMap";

    public static String getSchedulePlanMapKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(schedulePlanMap).append(keySplit).append(companyId).toString();
    }

    public static String getSchedulePlanMapHashKey(String schedulePlanId, int dayOfWeek) {
        return new StringBuffer().append(schedulePlanId).append(keySplit).append(dayOfWeek).toString();
    }

    /**
     * 国际化字段redis前缀
     */
    public static final String i18nKeyPrefix = "i18n_";

    /**
     * 返回国际化字段的redis的key值
     *
     * @return
     */
    public static String getI18NKey(String lan) {
        return new StringBuffer().append(i18nKeyPrefix).append(lan).toString();
    }

    /**
     * 链式结构的节点名集合，比如:a>b>c
     */
    public static final String companyTreeDataNodeNameMap = "companyTreeDataNodeNameMap";

    public static String getCompanyTreeDataNodeNameMapKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(companyTreeDataNodeNameMap).append(keySplit).append(companyId).toString();
    }

    /**
     * 储存公司的路由入口
     */
    public static final String routeEntrance = "routeEntrance";

    public static String getRouteEntranceKey(long companyId, String routeEntranceId, String media) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(routeEntrance).append(keySplit).append(companyId).append(keySplit).append(routeEntranceId).append(keySplit).append(media).toString();
    }

    public static final String emailListKey = "emailList";

    /**
     * 待发送邮件列表
     *
     * @param date
     * @return
     */
    public static String getEmailListKey(String date) {
        return new StringBuffer().append(reportKeysPrefix).append(emailListKey).append(keySplit).append(date).toString();
    }

    public static final String createExcel = "createExcel";
    public static final String sendEmail = "sendEmail";

    /**
     * 创建excel锁
     *
     * @return
     */
    public static String getCreateExcelKey() {
        return new StringBuffer().append(reportKeysPrefix).append(createExcel).toString();
    }

    /**
     * 发送邮件锁
     *
     * @return
     */
    public static String getSendEmailKey() {
        return new StringBuffer().append(reportKeysPrefix).append(sendEmail).toString();
    }

    /**
     * 对话结束缓存，默认30分钟
     */
    public static String chatExtInfoCache = "chatExtInfoCache";

    public static String getWechatChatExtInfoCacheKey(long companyId, String talkId) {
        return new StringBuffer().append(wechatKeysPrefix).append(chatExtInfoCache).append(keySplit).append(companyId).append(keySplit).append(talkId).toString();
    }

    /**
     * @param companyId
     * @param platForm
     * @param lan
     * @return
     */
    public static String i18NConfig = "i18NConfig";

    public static String getI18nConfigKey(long companyId, byte platForm, String lan) {
        return new StringBuffer().append(chatKeysPrefix)
                .append(i18NConfig).append(keySplit)
                .append(companyId).append(keySplit).append(platForm).append(keySplit).append(lan).toString();
    }

    public static String getI18nStaffConfigKey(long companyId, long staffId, byte platForm, String lan) {
        return new StringBuffer().append(chatKeysPrefix)
                .append(i18NConfig).append(keySplit)
                .append(companyId).append(keySplit)
                .append(staffId).append(keySplit)
                .append(platForm).append(keySplit).append(lan).toString();
    }

    /**
     * 非微信对话结束的缓存key
     */
    public static String chatEndInfoCache = "chatEndInfoCache";

    public static String getChatEndInfoCacheKey(long companyId, String talkId) {
        return new StringBuffer().append(chatKeysPrefix).append(chatEndInfoCache).append(keySplit).append(companyId).append(keySplit).append(talkId).toString();
    }

    /**
     * 离线窗口缓存
     */
    public static final String offlineBoxInfo = "offlineBoxInfo";

    public static String getChatProfileOfflineBoxInfoKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(offlineBoxInfo).append(keySplit).append(companyId).toString();
    }

    /**
     * 黑名单缓存Key
     */
    public static final String blackList = "blackList";

    public static String getBlackListKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(blackList).append(keySplit).append(companyId).toString();
    }


    /**
     * 普通访客-会员身份的对应关系
     */
    public static final String visitorOldNewRefMap = "visitorONRefMap";

    /**
     * 会员访客-普通访客的对应关系
     */
    public static final String visitorNewOldRefMap = "visitorNORefMap";

    public static String getVisitorOldNewMapKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(visitorOldNewRefMap).append(keySplit).append(companyId).toString();
    }

    public static String getVisitorNewOldMapKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(visitorNewOldRefMap).append(keySplit).append(companyId).toString();
    }

    /**
     * 插入黑名单时，防止kafka操作延迟造成主键重复的锁
     */
    public static final String blackListKafkaLock = "blackListKafkaLock";

    public static String getBlackListKafkaLockKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(blackListKafkaLock)
                .append(keySplit).append(companyId).append(keySplit).append(visitorId).toString();
    }

    /**
     * companyId和appId对应关系缓存
     */
    public static final String relationCompanyIdAppId = "relationCompanyIdAppId";

    public static final String getRelationCompanyIdAppIdKey() {
        return new StringBuffer().append(chatKeysPrefix).append(relationCompanyIdAppId).toString();
    }

    /**
     * 手动接入成功后会将此flag设置到缓存中。必须要有flag才能转到自动接入
     */
    private static final String manualConnectSuccessFlag = "manualConnectSuccessFlag";

    /**
     * 获取手动接入成功的flag的key
     *
     * @param companyId
     * @param openId
     * @return
     */
    public static final String getManualConnectSuccessKey(long companyId, String openId) {
        return new StringBuffer(ChatRedisKeys.wechatKeysPrefix).append(manualConnectSuccessFlag).append(keySplit).append(companyId).append(keySplit).append(openId).toString();
    }

    /**
     * 获取机器人回答的id的key
     */
    private static final String robotSearchId = "robotSearchId";

    /**
     * 获取机器人回答的id的key
     *
     * @return
     */
    public static final String getRobotSearchIdKey() {
        return new StringBuffer(ChatRedisKeys.robotKeysPrefix).append(robotSearchId).toString();
    }

    /**
     * 获取机器人上传的id
     */
    private static final String robotUploadId = "robotUploadId";

    /**
     * 获取机器人上传的id
     *
     * @return
     */
    public static final String getRobotUploadIdKey() {
        return new StringBuffer(ChatRedisKeys.robotKeysPrefix).append(robotUploadId).toString();
    }

    /**
     * admin 登录验证码
     */
    public static String verification = "admin_verification";//登录验证码

    public static String getVerification(String telNum) {
        return new StringBuffer().append(verification).append(keySplit).append(telNum).toString();
    }

    public static String chatInfoTopicConfig = "chatInfoTopicConfig";//对话主题配置

    public static String getChatInfoTopicConfigKey() {
        return new StringBuffer().append(chatProfileKeysPrefix).append(keySplit).append(chatInfoTopicConfig).toString();
    }

    /**
     * 注册时的tokenKey
     */
    public static final String regist = "regist";//注册

    public static String getRegistKey(String token) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(keySplit).append(regist).append(keySplit).append(token).toString();
    }

    /**
     * 修改帐号时的tokenKey
     */
    public static final String resetAccount = "resetAccount";//注册

    public static String getResetContextKey(String token) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(resetAccount).append(keySplit).append(token).toString();
    }

    /**
     * 找回密码时的tokenKey
     */
    public static final String retrievePassword = "retrievePassword";//找回密码

    public static String getRetrievePasswordKey(String token) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(keySplit).append(retrievePassword).append(keySplit).append(token).toString();
    }

    public static String customizeFormType = "customizeFormType";//自定义数据分析类型

    public static String getCustomizeFormTypeKey() {
        return new StringBuffer().append(chatProfileKeysPrefix).append(customizeFormType).toString();
    }

    /**
     * url推送配置
     */
    public static String pushUrlConfig = "pushUrlConfig";//url推送

    public static String getPushUrlConfigKey(Long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(pushUrlConfig).append(keySplit).append(companyId).toString();
    }

    public static String getPushUrlConfigHKey(Long menuId) {
        return new StringBuffer().append(keySplit).append(menuId).toString();
    }

    /**
     * 表单推送配置
     */
    @Deprecated
    public static String pushFormConfig = "pushFormConfig";//表单推送

    @Deprecated
    public static String getPushFormConfigKey(Long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(pushFormConfig).append(keySplit).append(companyId).toString();
    }

    @Deprecated
    public static String getPushFormConfigHKey(Long formId, String lan, String media) {
        return new StringBuffer().append(formId).append(keySplit).append(lan).append(keySplit).append(media).append(keySplit).toString();
    }

    /**
     * 表单推送配置
     */
    public static String pushFormMenuConfig = "pushFormMenuConfig";//表单推送

    public static String getPushFormMenuConfigKey(Long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(pushFormMenuConfig).append(keySplit).append(companyId)
                .toString();
    }

    public static String getPushFormMenuConfigHKey(Long formId) {
        return new StringBuffer().append(keySplit).append(formId).toString();
    }


    /**
     * 机器人对话
     */
    public static String companyRobotMap = "companyRobotMap";

    public static String getCompanyRobotMapKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyRobotMap).append(keySplit).append(companyId).toString();
    }

    /**
     * sdk路由规则
     */
    public static final String sdkRouteOgnlExp = "sdkRouteOgnlExp";

    public static String getChatProfileSDKRouteOgnlExpKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(sdkRouteOgnlExp).append(keySplit).append(companyId).toString();
    }

    /**
     * 推送表单参数列表
     */
    public static final String pushParamList = "pushParamList";

    public static String getPushParamListKey(Long companyId) {
        return new StringBuffer(chatProfileKeysPrefix).append(pushParamList).append(keySplit).append(companyId).toString();
    }

    public static final String clientCallbackRecordMap = "clientCallbackRecordMap";

    public static String getClientCallbackRecordMapKey(long companyId, long staffId) {
        return new StringBuffer(chatKeysPrefix).append(clientCallbackRecordMap).append(keySplit).append(companyId).append(keySplit).append(staffId).toString();
    }

    public static final String recentPushForm = "recentPushForm";

    public static String getRecentPushFormKey(Long companyId) {
        return new StringBuffer(recentPushForm).append(keySplit).append(companyId).toString();
    }

    public static String getRecentPushFormHKey(Long staffId) {
        return new StringBuffer(String.valueOf(staffId)).toString();
    }

    public static final String previousRobotRpcCount = "previousRobotRpcCount";//robotRpc调用次数统计，统计昨日的使用情况，用于给新注册的companyId确定分组

    public static String getPreviousRobotRpcCountKey() {
        return new StringBuffer(previousRobotRpcCount).toString();
    }

    public static String getPreviousRobotRpcCountHKey(String groupKey) {
        return groupKey;
    }

    public static final String robotRpcCount = "robotRpcCount";//今日robotRpc调用次数统计

    public static String getRobotRpcCountKey() {
        return new StringBuffer(robotRpcCount).toString();
    }

    public static String getRobotRpcCountHKey(String groupKey) {
        return groupKey;
    }

    public static final String robotKnowledgeBaseStatus = "robotKnowledgeBaseStatus";

    public static String getRobotKnowledgeBaseStatusKey() {
        return new StringBuffer(robotKeysPrefix).append(robotKnowledgeBaseStatus).toString();
    }

    public static String getRobotKnowledgeBaseStatusHKey(Long companyId) {
        return String.valueOf(companyId);
    }

    /**
     * 可用查询百度关键字client端
     */
    private static String bceClientList = "bceClientList";

    public static String getBceClientListKey() {
        return new StringBuffer(chatKeysPrefix).append(bceClientList).toString();
    }

    /**
     * 异步获取访客关键字map
     */
    private static String visitorBceEqidKeywordMap = "visitorBceEqidKeywordMap";

    public static String getVisitorBceEqidKeywordMapKey(String bceRqid) {
        return new StringBuffer(chatKeysPrefix).append(visitorBceEqidKeywordMap).append(keySplit).append(bceRqid).toString();
    }

    /**
     * 请求百度关键字消息列表
     */
    private static String refererQueryMap = "refererQueryMap";

    public static String getRefererQueryMapKey() {
        return new StringBuffer(chatKeysPrefix).append(refererQueryMap).toString();
    }

    /**
     * 离线消息二次分配列表
     */
    private static String offlineRedistributeMap = "offlineRedistributeMap";

    public static String getOfflineRedistributeMapKey(long companyId) {
        return new StringBuffer(chatKeysPrefix).append(offlineRedistributeMap).append(keySplit).append(companyId).toString();
    }

    /**
     * 微信留言超时配置
     */
    private static final String wechatOfflineTimeout = "wechatOfflineTimeout";

    public static String getWechatOfflineTimeoutKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(wechatOfflineTimeout).append(keySplit).append(companyId).toString();
    }

    /**
     * 已处理留言 缓存
     */

    private static final String handledOfflineRecord = "handledOfflineRecord";

    public static String getHandledOfflineRecordKey(long companyId, long recordId) {
        return new StringBuffer().append(chatKeysPrefix).append(handledOfflineRecord).append(keySplit).append(companyId).append(keySplit).append(recordId).toString();
    }

    /**
     * 已处理待处理 缓存
     */

    private static final String handledJobRecord = "handledJobRecord";

    public static String getHandledJobRecordKey(long companyId, long staffId, long recordId) {
        return new StringBuffer().append(chatKeysPrefix).append(handledJobRecord).append(keySplit).append(companyId).append(keySplit).append(staffId).append(keySplit).append(recordId).toString();
    }

    private static final String jobDistributeCrmContactsCache = "jobDistributeCrmContactsCache";

    /**
     * 设置待处理后，缓存30分钟
     *
     * @param companyId
     * @param staffId
     * @param crmContactsId
     * @return
     */
    public static final String getJobDistributeCrmContactsCache(long companyId, long staffId, long crmContactsId) {
        return new StringBuffer().append(chatKeysPrefix).append(jobDistributeCrmContactsCache).append(keySplit).append(companyId)
                .append(keySplit).append(staffId).append(keySplit).append(crmContactsId).toString();
    }

    /**
     * 留言过程信息缓存
     */
    private static final String offlineExtInfo = "offlineExtInfo";

    public static String getOfflineExtInfoKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(offlineExtInfo).append(keySplit).append(companyId).toString();
    }

    /**
     * 机器人对话计数
     */
    private static final String robotMsgCount = "robotMsgCount";

    public static String getRobotMsgCountKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(robotMsgCount).append(keySplit).append(companyId).toString();
    }

    public static String getRobotMsgCountHKey(String talkId) {
        return talkId;
    }

    /**
     * 离线消息分配策略
     */
    private static final String offlineAllocatePolicyMap = "offlineAllocatePolicyMap";

    public static String getOfflineAllocatePolicyMapKey() {
        return new StringBuffer().append(chatKeysPrefix).append(offlineAllocatePolicyMap).toString();
    }

    /**
     * 离线消息分配配置详情：手动、自动实时、自动定时
     */
    private static final String offlineAllocateConfigMap = "offlineAllocateConfigMap";

    public static String getOfflineAllocateConfigMapKey() {
        return new StringBuffer().append(chatKeysPrefix).append(offlineAllocateConfigMap).toString();
    }

    /**
     * 离线消息分配配置详情：路由指派
     */
    private static final String offlineAllocateRouteMap = "offlineAllocateRouteMap";

    public static String getOfflineAllocateRouteMapKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(offlineAllocateRouteMap).append(keySplit).append(companyId).toString();
    }

    public static String getOfflineAllocateRouteMapHashKey(String routeId, int dayOfWeek) {
        return new StringBuffer().append(routeId).append(keySplit).append(dayOfWeek).toString();
    }

    private static final String xcxVisitorRoute = "xcxVisitorRoute";

    public static String getXcxVisitorRouteKey(long companyId, long xcxId) {
        return new StringBuffer().append(chatKeysPrefix).append(xcxVisitorRoute).append(keySplit).append(companyId).append(keySplit)
                .append(xcxId).toString();
    }

    private static final String weiboVisitorRoute = "weiboVisitorRoute";

    public static String getWeiboVisitorRouteKey(long companyId, String weiboId) {
        return new StringBuffer().append(chatKeysPrefix).append(xcxVisitorRoute).append(keySplit).append(companyId).append(keySplit)
                .append(weiboId).toString();
    }

    /**
     * 留言超时配置：全渠道
     */
    private static final String offlineTimeout = "offlineTimeout";

    public static String getOfflineTimeoutKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(offlineTimeout).append(keySplit).append(companyId).toString();
    }

    /**
     * 自定义渠道接入对话配置缓存：hash结构，key为appId
     */
    private static String customChannelConfigMap = "customChannelConfigMap";

    public static String getCustomChannelConfigMapKey() {
        return new StringBuffer().append(chatKeysPrefix).append(customChannelConfigMap).toString();
    }

    /**
     * 自定义渠道接入对话配置缓存：hash结构，key为companyId
     */
    private static String customChannelConfigList = "customChannelConfigList";

    public static String getCustomChannelConfigListKey() {
        return new StringBuffer().append(chatKeysPrefix).append(customChannelConfigList).toString();
    }

    /**
     * 自定义渠道路由
     */
    private static final String customRouteOgnlExp = "customRouteOgnlExp";

    public static String getChatProfileCustomRouteOgnlExpKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(customRouteOgnlExp).append(keySplit).append(companyId).toString();
    }

    /**
     * 访问限制
     */
    private static final String requestLimitKey = "requestLimit";

    public static String getRequestLimitKey(String suffix) {
        return new StringBuffer().append(chatKeysPrefix).append(requestLimitKey).append(keySplit).append(suffix).toString();
    }

    private static final String wechatRobotConfig = "wechatRobotConfig";

    public static String getWechatRobotConfigKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(wechatRobotConfig).append(keySplit).append(companyId).toString();
    }

    public static String getWechatRobotConfigHKey(long styleId) {
        return new StringBuffer(String.valueOf(styleId)).toString();
    }

    private static final String robotChatBoxConfig = "robotChatBoxConfig";

    public static String getRobotChatBoxKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(robotChatBoxConfig).append(keySplit)
                .append(companyId).toString();
    }

    public static String getRobotChatBoxHKey(String lan) {
        return new StringBuffer(String.valueOf(lan)).toString();
    }

    public static String getResponseInTimeRateConfigKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(companyChatConfig).append(keySplit)
                .append(companyId).toString();
    }

    private static final String companyCustomConfig = "companyCustomConfig";

    public static String getCompanyCustomConfig(long companyId, byte type) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(companyCustomConfig).append(keySplit)
                .append(companyId).append(keySplit).append(type).toString();
    }

    /**
     * 机器人对话过程缓存
     */
    private static final String robotExtInfo = "robotExtInfo";

    public static String getRobotExtInfoKey(long companyId) {
        return new StringBuffer().append(chatKeysPrefix).append(robotExtInfo).append(keySplit).append(companyId).toString();
    }

    /**
     * 机器人对话session
     */
    private static final String robotSessionMap = "robotSessionMap";

    public static String getRobotSessionMapKey(long companyId, String visitorId) {
        return new StringBuffer().append(chatKeysPrefix).append(robotSessionMap).append(keySplit).append(companyId).append(keySplit).append(visitorId).toString();
    }

    /**
     * 用户自动登录cookie(yichat_user、admin_user)
     */
    private static final String principalAutoAuthCookieInfo = "principalAutoAuthCookieInfo";

    public static String getPrincipalAutoAuthCookieInfo(String principal) {
        return new StringBuffer().append(commonKeysPrefix).append(principalAutoAuthCookieInfo).append(keySplit).append(principal).toString();
    }

    /**
     * 是否开启自动登录cookie检测
     */
    private static final String isSkipCheckCookie = "isSkipCheckCookie";

    public static String getIsSkipCheckAutoLoginCookie() {
        return new StringBuffer().append(commonKeysPrefix).append(isSkipCheckCookie).toString();
    }

    /**
     * SDK留言超时配置
     */
    private static final String sdkOfflineTimeout = "sdkOfflineTimeout";

    public static String getSdkOfflineTimeoutKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(sdkOfflineTimeout).append(keySplit).append(companyId).toString();
    }

    /**
     * 微信机器人超时配置
     */
    private static final String weChatRobotTimeout = "weChatRobotTimeout";

    public static String getWeChatRobotTimeoutKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(weChatRobotTimeout).append(keySplit).append(companyId).toString();
    }

    /**
     * 导出任务锁，每个公司同时只能执行一个导入任务
     */
    private static final String exportTaskLock = "exportTaskLock";

    public static String getExportTaskLockKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(exportTaskLock).append(keySplit).append(companyId).toString();
    }

    /**
     * 永不回答集合
     */
    private static final String robtoNeverAnswerSet = "robtoNeverAnswerSet";

    public static String getRobtoNeverAnswerSet(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append(robtoNeverAnswerSet).append(keySplit).append(companyId).toString();
    }

    /**
     * 阿里云文件上传凭证
     */
    private static final String aliyunUploadSecurityToken = "aliyunUploadSecurityToken";

    public static String getAliyunUploadSecurityTokenKey() {
        return new StringBuffer().append(wechatKeysPrefix).append(aliyunUploadSecurityToken).toString();
    }

    /**
     * session attribute集合
     */
    private static final String sessionAttributeMap = "sessionAttributeMap";

    public static String getSessionAttributeMapKey(String sessionId) {
        return new StringBuffer().append(chatKeysPrefix).append(sessionAttributeMap).append(keySplit).append(sessionId).toString();
    }

    public static final String getTranslateConfigCacheKey(long companyId) {
        return new StringBuffer().append(chatProfileKeysPrefix).append("translageConfig").append(keySplit).append(companyId).toString();
    }

    /**
     * 客服端自定义域名集合
     */
    private static final String staffSpecialDomainMap = "staffSpecialDomainMap";

    public static String getStaffSpecialDomainMapKey() {
        return new StringBuffer(chatKeysPrefix).append(staffSpecialDomainMap).toString();
    }

    /**
     * 向第三方开发者post数据msgId
     */
    private static final String postDataMsgId = "postDataMsgId";

    public static String getpostDataMsgIdKey() {
        return new StringBuffer(chatApiKeysPrefix).append(postDataMsgId).toString();
    }

    /**
     * task任务执行集合
     */
    private static final String taskExecutorMap = "taskExecutorMap";

    public static String getTaskExecutorMapKey(String className, long companyId) {
        return new StringBuffer().append(ChatRedisKeys.chatKeysPrefix).append(ChatRedisKeys.taskExecutorMap)
                .append(ChatRedisKeys.keySplit).append(className).append(ChatRedisKeys.keySplit).append(companyId).toString();
    }

    /**
     * 客服推送token集合
     */
    public static final String staffPushInfoMap = "staffPushInfoMap";

    public static String getStaffPushInfoMapKey() {
        return new StringBuffer().append(ChatRedisKeys.chatKeysPrefix).append(ChatRedisKeys.staffPushInfoMap).toString();
    }

    /**
     * 机器人更新索引任务列表
     */
    private static final String robotWriteIdxTask = "robotWriteIdxTask";

    public static final String getRobotWriteIdxTaskKey(long companyId) {
        return new StringBuffer().append(robotKeysPrefix).append(robotWriteIdxTask).append(keySplit).append(companyId).toString();
    }

    /**
     * 导入/导出的记录详情缓存
     */
    private static final String historyConfiguration = "historyConfiguration";

    /*历史记录详情的存储map集合的key*/
    public static final String getHistoryConfigurationMapKey() {
        return new StringBuffer().append(commonKeysPrefix).append(historyConfiguration).toString();
    }

    /*历史记录详情的存储field*/
    public static final String getHistoryConfigurationField(long companyId, long staffId, long historyId) {
        return new StringBuffer().append(companyId).append(keySplit).append(staffId).append(keySplit).append(historyId).toString();
    }

    /**
     * 处理历史记录缓任务锁
     */
    private static final String processHistoryCacheLocker = "processHistoryCacheLocker";

    public static final String getProcessHistoryCacheLockKey() {
        return new StringBuffer().append(commonKeysPrefix).append(processHistoryCacheLocker).toString();
    }

    /**
     * 存储待归档的RobotInfo的集合名
     * #3631 chenmohan 2018/8/22
     */
    private static final String finishedRobotInfoSet = "finishedRobotInfo";

    public static final String getFinishedRobotInfoSetKey() {
        return new StringBuffer().append(robotKeysPrefix).append(finishedRobotInfoSet).toString();
    }

    /**
     * 获取文件表单上传从七牛切换为阿里云的次数缓存key
     */
    private static final String fileUploadSwitchCount = "fileUploadSwitchCount";

    public static final String getFileUploadSwitchCountKey(String prefix) {
        return new StringBuffer().append(prefix).append(fileUploadSwitchCount).toString();
    }

    /**
     * 对话发起详情缓存
     */
    public static final String chatLaunchDetail = "chatLaunchDetail";

    public static String getChatLaunchDetailKey(long companyId, String visitorId, String talkId) {
        return new StringBuffer().append(chatKeysPrefix).append(chatLaunchDetail).
                append(companyId).append(keySplit).append(visitorId).append(keySplit).append(talkId).toString();
    }

    /**
     * 离线消息分配锁
     */
    private static final String offlineMsgAcdLock = "offlineMsgAcdLock";

    public static final String getOfflineMsgAcdLockKey() {
        return new StringBuffer().append(chatProfileKeysPrefix).append(offlineMsgAcdLock).toString();
    }

    /**
     * 10001对话转接列表消息
     */
    public static final String transferChatList = "transferChatList";

    public static String getTransferChatListKey(long companyId) {
        return new StringBuffer().append(ChatRedisKeys.chatKeysPrefix).append(ChatRedisKeys.transferChatList).append(keySplit).append(companyId).toString();
    }
}
